﻿using System.Windows;
using System.Windows.Media;

namespace SStuff.FlowControls
{
    /// <summary>
    /// ItemContainer for the FlowItemsControl2D control
    /// It is the object on which the layout algorithm will apply
    /// </summary>
    public class FlowItem2D : FlowItemBase, IFlowItem2D 
    {
        readonly CompositeTransform _compositeTransform = new CompositeTransform();
        public FlowItem2D()
        {
            DefaultStyleKey = typeof(FlowItem2D);

            // Silverlight supports natively CompositeTransforms (WPF not so we use an interop layer that has the same public interface than Silverlight Composite transform)
#if SILVERLIGHT
            RenderTransform = _compositeTransform;
#else
            RenderTransform = _compositeTransform.InnerTransform;
#endif
            RenderTransformOrigin = new Point(0.5, 0.5);

            // for better performance, we apply Bitmap Caching on FlowItems
            CacheMode = new BitmapCache();
        }

        #region IFluidItem2D Members

        /// <summary>
        /// Get the Composite transform associated with the item.
        /// </summary>
        public CompositeTransform Transform2D
        {
            get { return _compositeTransform; }
        }

        #endregion
    }
}
